<?php
class PDODAL
{
	protected $db;
	
	protected $sql;
	
	protected $params;
	
	protected $database;
	
	protected $mode;
	
	function PDODAL($sql, $params=null, $database = '', $mode = PDO::FETCH_ASSOC)
	{
		$this->db = new PDO('mysql:host=192.168.0.145;dbname=ringring','d6', 'music');
				
		$this->sql = $sql;
		$this->params = $params;
		$this->mode = $mode;
	}
	
	private function execute($stmt)
	{		
		try 
		{
			if ($this->params != null)
			{
				$stmt->execute($this->params);
			}
			else 
			{
				$stmt->execute();
			}			
			
		}catch (Exception $e)
		{			
			$stmt = null;
			Propel::log($e->getMessage(), Propel::LOG_ERR);						
			throw new PropelException($e);	
		}
	}
	
	public function doSelect()
	{
		$stmt = $this->db->prepare($this->sql);
		$this->execute($stmt);
		
		$result = $stmt->fetch($this->mode);
		$stmt = null;
		return $result;				
	}
	
	public function doUpdate()
	{
		$stmt = $this->db->prepare($this->sql);
		$this->execute($stmt);
	}
}
?>